import { INCREMENT, DECREMENT } from "./constant";

export const createIncrementAction = (data) => ({
    type: INCREMENT,
    data: data,
});

export const createDecrementAction = (data) => ({
    type: DECREMENT,
    data: data,
});

// 异步action，返回值为函数
// 异步action中一般都会调用同步函数，异步action不是必须的
export const createIncrementAsyncAction = (data, time) => {
    return (dispatch) => {
        setTimeout(() => {
            dispatch(createIncrementAction(data));
        }, time);
    };
};
